<?php
namespace Home\Controller;
use Think\Controller;
class JobController extends HomeController {

	/**
	 * 初始化
	 */
	public function __construct() {
		parent::__construct();
	}
	
	/**
	 * 新闻列表
	 */
	public function index() {
		$id = I('get.id','','intval');
		$key = I('get.keyword','','strip_tags');
		if(!empty($key)) {
			$where['title'] = array('like','%'.$key.'%');
		}
		//$where['cid'] = $id;
		$where['attr'] = I('get.attr','','intval');
		$data = M('job')->where($where)->select(); 
		$this->assign('list',$data);

		$banner = M('banner')->select();
		$this->assign('banner',$banner);
		/**jssdk***/
		$signPackage = $this->signPackage;
		$signPackage['title'] = "苗木通讯录";
		$signPackage['link'] = 'http://'.C('DOMAIN').U('Job/index');
		$signPackage['desc'] = "众里寻他千百度，苗友尽在通讯录，苗商驰骋天地间，买卖沟通更方便。";
		$signPackage['imgUrl'] = 'http://zhumeng777.com/Uploads/2016-09-18/57de84aca6a35.jpg';
		$this->assign('signPackage',$signPackage);
		/****/
		$this->display();
	}

	public function test() {
	$url =  U('Job/test',$_GET);
	$urls = str_replace('.html','',$url);
	echo $urls;
	die();
		
		$id = I('get.id','','intval');
		
		$data = M('job_copy')->limit('0,15')->select();
		$this->assign('list',$data);
		$this->assign('page',1);

		$banner = M('banner')->select();
		$this->assign('banner',$banner);

		/**jssdk***/
		$signPackage = $this->signPackage;
		$signPackage['title'] = "苗木通讯录";
		$signPackage['link'] = 'http://'.C('DOMAIN').U('Job/index');
		$signPackage['desc'] = "众里寻他千百度，苗友尽在通讯录，苗商驰骋天地间，买卖沟通更方便。";
		$signPackage['imgUrl'] = 'http://zhumeng777.com/Uploads/2016-09-18/57de84aca6a35.jpg';
		$this->assign('signPackage',$signPackage);
		/****/

		$this->display();
	}

	public function ajax_test() {
		/****/
		$page = intval($_GET['p']) < 1?1:intval($_GET['p']);
		$page++;
		$Job = M('job_copy'); 
		$list = $Job->page($page.',15')->select();
		foreach($list as $key=>$value) {
			$list[$key]['title'] = mbsubstr($value['title'],0,30);
		}
		echo json_encode($list);
		/****/
	}

	/**
	 * 内容页
	 */
	public function info() {
		$id = I('get.id','','intval');
		if(!empty($id)) {
			$info = M('job')->find($id);
			if(empty($info)) {
				die('not find this data');
			}
			$this->assign('info',$info);
		}
		$class = D('Admin/job_class')->kselect();
		$this->assign('class',$class);
		$this->assign('attr',[0=>'招聘信息',1=>'求职信息']);

		/**jssdk***/
		$signPackage = $this->signPackage;
		$signPackage['title'] = "苗木通讯录";
		$signPackage['link'] = 'http://'.C('DOMAIN').U('Job/info',array('id'=>$id));
		$signPackage['desc'] = $info['title'];
		$signPackage['imgUrl'] = 'http://zhumeng777.com'.$info['img'];
		$this->assign('signPackage',$signPackage);
		/****/

		$this->display();
	}
	
}
